//保存用户信息
function saveUserInfos(v) {

	var realname = $("#realname").val(); //获取用户姓名
	var birthyear = $('#birthyear option:selected').text();
	var birthmonth = $('#birthmonth option:selected').text();
	var birthday = $('#birthday option:selected').text();
	var birthprovince = $('#birthprovince option:selected').text();
	var bloodtype = $('#bloodtype option:selected').text();
	var resideprovince = $('#resideprovince option:selected').text();
	var education = $('#education option:selected').text();
	//	var actionurl = $('form').attr('action');// 提交路径
	//	var checkurl = $('form').attr('check');// 验证路径
	var formData = new Object();
	var data = $(":input").each(function() {
		formData[this.name] = $("#" + this.name).val();
	});
	var url = "userInfoController.do?saveUserInfos&options=" + v;
	$.ajax({
		async : false,
		cache : false,
		type : 'POST',
		url : url,
		data : formData,
		success : function(data) {
			var d = $.parseJSON(data);
			if (d.success) {
				alert(d.msg);
				// var url= "/indexController.do?index";
				// location.href = url;
				//				setTimeout("window.location.href='" + actionurl + "'", 1000);
			} else {
				alert(d.msg);
			}
		},

		error : function() {// 请求失败处理函数
			alert("注册信息有误请重新填写！");
		}

	});
}

//上传图片
$(function() {

	//触发click方法
	$('#defaultImage').on('click', function() {
		$('#fileInput').click();
	});
	//触发click方法
	$('#imageUploadLink').on('click', function() {
		$('#fileInput').click();
	});
});

function uploadHead() {
	$.ajaxFileUpload({
		url : "imagesController.do?ajaxUpload",//需要链接到服务器地址 
		secureuri : false,
		fileElementId : "fileInput",//文件选择框的id属性
		dataType : 'json', //json
		success : function(data) {
			var path = jQuery.parseJSON(data).imagePath;
			var oldName = jQuery.parseJSON(data).oldName;
//			$("#defaultImage").attr("src","imagesController.do?readImage&imagePath=" + path);
			document.getElementById('defaultImage').innerHTML =  path;
			$('#imageAddress').val(path);
			$('#defaultImage').css("display", "block");
			$('#oldName').val(oldName);
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			alert('上传失败！');
		}
	});
};